package com.zhuhjay.controller;

import com.zhuhjay.model.dto.FileChunkDto;
import com.zhuhjay.service.SystemFileService;
import com.zhuhjay.utils.result.Result;
import com.zhuhjay.utils.result.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Zhuhjay
 * @since 2023-02-07
 */
@Api(tags = "系统文件控制器")
@RestController
@RequestMapping("/file")
public class SystemFileController {

    @Resource
    private SystemFileService fileService;

    @ApiOperation("文件上传检查")
    @GetMapping("upload/{identifier}")
    public Result uploadCheck(@PathVariable String identifier) {
        return ResultBean.ok().data(fileService.check(identifier));
    }

    @ApiOperation("文件上传")
    @PostMapping("upload")
    public Result upload(FileChunkDto chunkInfo) {
        return fileService.upload(chunkInfo);
    }

}
